<template>
  <div class="responsib">
    <!--价目表列表弹窗-->
    <el-dialog
      v-dialogDrag
      class="dialog-class"
      :title="$t('menu.salesPrice')"
      model
      :visible.sync="fuzeRegion"
      :close-on-click-modal="false"
      width="60%"
      destroy-on-close
      :before-close="handleClose"
    >
      <div style="margin-bottom: 10px;text-align: left">
        <span>{{ $t('shop.name1') }}</span>
        <el-input v-model.trim="fuzePagination.fname" size="mini" style="width: 200px" />
        <el-button type="primary" size="mini" style="margin-left: 20px" @click="fuzehandle">{{ $t('btn.search') }}</el-button>
      </div>
      <jc-table
        :table-header="fuzeHeader"
        :table-data="tableFuzeData"
        table-height="46vh"
        @clickRow="fuzeRow"
      >
        <template v-slot:tagSlot="col">
          <el-tag :type="col.scope.row.stateColor">{{ col.scope.row.fdocumentStatus }}</el-tag>
        </template>
      </jc-table>
      <jc-pagination
        v-show="fuzePagination.total > 0"
        :total="fuzePagination.total"
        :page.sync="fuzePagination.pageNum"
        :limit.sync="fuzePagination.pageSize"
        @pagination="fuzehandle"
      />
    </el-dialog>
  </div>
</template>
<script>
import {
  queryBuyerList
} from '@/api/marketManage/customer/createCustomer'
import { toMxAmina } from '@/components/ToMxamineState'

export default {
  props: {
    supplier: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      fuzeRegion: true, // 负责人
      // 负责人
      fuzePagination: {
        fname: '',
        total: 0,
        pageNum: 1, // 当前页
        pageSize: 20 // 每页显示多少条数据
      },
      tableFuzeData: [],
      fuzeHeader: [
        { label: this.$t('market.priceNo'), prop: 'fbillNo' },
        { label: this.$t('market.priceList'), prop: 'listName' },
        { label: this.$t('market.supplier'), prop: 'fsupplier' },
        { label: this.$t('market.currency2'), prop: 'fcurrency' },
        { label: this.$t('shop.state'), type: 'tag', prop: 'fdocumentStatus' },
        { label: this.$t('market.tax'), prop: 'fisIncludedTax' }
      ],
      prodValue: { fstafname: '', fstaffid: '' }
    }
  },
  created() {
    this.fuzehandle()
  },
  methods: {
    // 价目表
    fuzehandle() {
      queryBuyerList({ ...this.fuzePagination, fsupplierId: this.supplier }).then(res => {
        if (res.code === 0) {
          this.tableFuzeData = res.data.array.map(res => {
            res.fisIncludedTax === 1 ? res.fisIncludedTax = '是' : res.fisIncludedTax = '否'
            return toMxAmina(res)
          })
          this.fuzePagination.total = res.data.total
        }
      })
    },
    // 选中价目表
    fuzeRow(item) {
      this.$emit('respon', item)
    },
    // 关闭前回调
    handleClose() {
      this.$emit('respon', '')
    }
  }
}
</script>

<style scoped lang="scss">
</style>
